<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSanitationToiletsTable extends Migration
{
    /**
     * Run the migrations.
     *站点列表->公厕数据表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sanitation_toilets', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('公厕名称');
            $table->integer('number')->unsigned()->comment('编号');
            $table->string('address')->comment('公厕地址');
            $table->integer('area_id')->unsigned()->comment('所属区域')->nullable();
            $table->foreign('area_id')->references('id')->on('carareas')->onDelete('set null');
            $table->point('location')->comment('经纬度')->nullable();
            $table->string('company')->comment('归属业主')->nullable();
            $table->integer('type')->comment('厕所类型 0临时厕所 1旅游厕所 2普通厕所')->nullable();
            $table->integer('man_squatting')->unsigned()->comment('男蹲位')->nullable();
            $table->integer('woman_squatting')->unsigned()->comment('女蹲位')->nullable();
            $table->integer('restroom')->unsigned()->comment('无障碍卫生间')->nullable();
            $table->integer('third_toilet')->unsigned()->comment('第三卫生间')->nullable();
            $table->integer('frequency')->unsigned()->comment('保洁频次')->nullable();
            $table->tinyInteger('status')->unsigned()->comment('厕所状态')->nullable();
            $table->string('device_name')->comment('设备名称')->nullable();
            $table->char('imei',20)->comment('设备唯一imei')->nullable();
            $table->integer('principal_id')->unsigned()->comment('负责人id')->nullable();
            $table->foreign('principal_id')->references('id')->on('employees')->onDelete('set null');
            $table->string('phone',20)->comment('电话')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sanitation_toilets');
    }
}
